//	ID : pallab81
// 	PROG : 11518
// 	LANG : C++
// 	2011-07-06-20.39.17 Wednesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long

int n,m,l;
vector< vector<int> > path;
vector<int> vis;
inline void read(){
    scanf("%d %d %d",&n,&m,&l);
    path.assign(n+5, vector<int>() );

    for(int i=0;i<m;++i){
        int x,y;
        scanf("%d %d",&x,&y);
        path[x].push_back(y);
    }
}
inline void go(int now){
    //cout<<now<<" ";bip;
    if( vis[now]==-1 ){
        vis[now]=1;
        for(int i=0;i<(int)path[now].size();++i){
            go( path[now][i] );
        }
    }
}
inline void proc(){
    vis.assign(10010,-1);
    for(int i=0;i<l;++i){
        int now ;
        scanf("%d",&now);
        go(now);
    }

    int tot = count(vis.begin(),vis.end(),1);
    printf("%d\n",tot);

}

int main(){
    int cases;
    scanf("%d",&cases);
    while(cases--){
        read();
        proc();
    }

return 0;
}

